package com.simpleim.starter.processor;

import com.simpleim.starter.server.ServerSession;
import io.netty.channel.Channel;

public abstract class AbstractServerProcesser implements ServerProcesser {

    protected String getKey(Channel ch) {
        return ch.attr(ServerSession.KEY_USER_ID).get();
    }

    protected void setKey(Channel ch, String userId) {
        ch.attr(ServerSession.KEY_USER_ID).set(userId);
    }

    protected void checkUser(Channel channel) throws Exception{
        if (null == getKey(channel))
            throw new Exception("此用户，没有登录成功");
    }
}
